package com.ylx.excel;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.Environment;

@Slf4j
@ServletComponentScan//扫描web原生注解  可以加过滤器等
@SpringBootApplication//springboot启动类
@ComponentScan("com.ylx")
@EnableCaching//开启缓存注解扫描功能
@MapperScan({"com.ylx.excel.mapper"})//扫描数据访问层的接口的包名
public class ExcelApplication {

    @Autowired
    private Environment env;

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(ExcelApplication.class, args);
        ExcelApplication application = context.getBean(ExcelApplication.class);
        application.envPram();
    }

    public void envPram() {
        String databaseUrl = env.getProperty("spring.datasource.druid.url");
        log.info("================>项目启动完毕<==============");
        log.info("=====>数据库地址： {}",databaseUrl);
    }
}
